/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Animation;

import Scenery.BaseCharacter;
import com.jme3.math.FastMath;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import Scenery.BaseSprite;
import com.jme3.math.Vector3f;

/*
 * 
 * @author: Ziden
 * 
 */

public abstract class Animation {
    
    protected abstract void buildFrame();
    public abstract void performFrame();
    public abstract void gotoInitialState();
    public abstract String getName();
    public abstract void saveInitialState();
    protected abstract float getCicleRunTime();
    protected boolean frozenOnPerform = false;
    protected Object parameter;
    protected boolean finished = false;
    protected BaseCharacter animationBody;
    protected float [][] animationFrames;
    protected boolean canceled = false;
    protected int frame = 0; 
    protected int maxFrame = 0;
    protected int storedValues = 1;
    protected int cicle = 0;
    
    public Animation(BaseCharacter s, int maxFrames) {
        this.maxFrame = maxFrames;
        this.animationBody = s;
        this.saveInitialState();
        this.gotoInitialState();
    }
    
    protected void buildAnimation() {
        animationFrames = new float[maxFrame][storedValues];
        for(frame = 0 ; frame < maxFrame ; frame+=1) {
            buildFrame();
        }
        frame = 0;
    }

    public void perform() {
        performFrame();
        frame++;
        if(frame >= maxFrame) {
            frame = 0;
            finished = false;
        }
    }
    
    public boolean hasFinished() { return finished; }
    public boolean freezesOnPerform() { return this.frozenOnPerform; }
    public Object getParameter() { return parameter; }
    public void setParameter(Object p) { this.parameter = p; }
}
